import PublishAbstract from './abstract/publish'

export default class RecordPulisher extends PublishAbstract {
  async notify(data: any) {
    let currentData = data
    try {
      for (const observer of this.observerList) {
        const result = await observer.execute(currentData)
        if (!result.success) return false
        currentData = result.data
      }
      return true
    } catch (e) {
      console.error('执行出错了', e)
    } finally {
      console.log('执行完成了')
    }
  }

  destory() {
    this.observerList.forEach((observer) => observer.destory())
  }
}
